package com.yyds.controller;

import com.yyds.common.MyJSON;
import com.yyds.common.R;
import com.yyds.pojo.UserUser;
import com.yyds.service.UserUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.Map;

//总用户的web层
@RestController
@RequestMapping("/admin/user/user")
public class UserUserController {
    @Autowired
    private UserUserService userService;

//    添加个人信息
    @RequestMapping("/adduseruser")
    public R addUserUser(UserUser userUser){
        userUser.setUser_starttime(new Date());
        int result = userService.addUserUser(userUser);
        if (result == 1) {
            return R.ok();
        } else {
            return R.error().message("添加失败");
        }
    }
//    删除用户个人信息
    @RequestMapping("/deleteuseruser")
    public R deleteUserUser(Integer user_id){

        int result = userService.deleteUserUser(user_id);
        if (result == 1) {
            return R.ok();
        } else {
            return R.error();
        }
    }
//    所有用户信息更新
    @RequestMapping("/updateuseruser")
    public R updateuseruser(UserUser userUser){
        int result = userService.updateuseruser(userUser);
        if (result == 1) {
            return R.ok();
        } else {
            return R.error();
        }
    }
//    用户列表查询
    @RequestMapping("/queryalluseruser")
    public MyJSON<UserUser> UserList(@RequestParam Map<String,Object> signList){

        return userService.queryalluseruser(signList);
    }
    //    用户部分删除
    @RequestMapping("/deletesuseruser")
    public R deletesuseruser(String str) {
        System.out.println("deletesuseruser str" + str);
        Integer i = userService.deletesuseruser(str);
        return i > 0 ? R.ok() : R.error();
    }

}
